home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Request.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  3.3 KB  |  90 lines

  1. package symantec.itools.db.pro;
  2.  
  3. import java.util.Hashtable;
  4. import java.util.Properties;
  5. import symjava.sql.SQLException;
  6.  
  7. public class Request extends Properties {
  8.    public static final String UNIQUE = new String("0");
  9.    public static final String UNIQUE_MODIFIED = new String("1");
  10.    public static final String ALL = new String("2");
  11.    public static final String REC_POS_FIRST = new String("1");
  12.    public static final String REC_POS_NEW = new String("2");
  13.    public static final String REC_POS_NOPOS = new String("3");
  14.    private ConnectionInfo _conn;
  15.    private String _sql;
  16.    protected Session _sess;
  17.  
  18.    public Request(Session sess, ConnectionInfo conn) {
  19.       this._sess = sess;
  20.       this._conn = conn;
  21.    }
  22.  
  23.    public void setRequestProperties(Properties requestProps) {
  24.       this.transferProperties(requestProps);
  25.    }
  26.  
  27.    public Properties getRequestProperties() {
  28.       return this;
  29.    }
  30.  
  31.    public void setSQL(String sql) {
  32.       this._sql = sql;
  33.    }
  34.  
  35.    public String getSQL() {
  36.       return this._sql;
  37.    }
  38.  
  39.    public void setConnectionInfo(ConnectionInfo conn) {
  40.       this._conn = conn;
  41.    }
  42.  
  43.    public ConnectionInfo getConnectionInfo() {
  44.       return this._conn;
  45.    }
  46.  
  47.    public RelationView executeRequest() throws SQLException {
  48.       return this._sess.createView(this._conn, this._sql, this);
  49.    }
  50.  
  51.    protected int getOptConc() {
  52.       String value = ((Properties)this).getProperty("optConc", UNIQUE_MODIFIED);
  53.       Integer i = Integer.valueOf(value);
  54.       return i;
  55.    }
  56.  
  57.    protected String getInitialRecordPos() {
  58.       return ((Properties)this).getProperty("recPosition", REC_POS_NOPOS);
  59.    }
  60.  
  61.    private void transferProperties(Properties newProps) {
  62.       ((Hashtable)this).put("optConc", newProps.getProperty("optConc", UNIQUE_MODIFIED));
  63.       ((Hashtable)this).put("recPosition", newProps.getProperty("recPosition", REC_POS_NOPOS));
  64.    }
  65.  
  66.    public void setOptimisticConcurrency(String setting) {
  67.       if (setting.equals("All")) {
  68.          ((Hashtable)this).put("optConc", ALL);
  69.       } else if (setting.equals("Unique")) {
  70.          ((Hashtable)this).put("optConc", UNIQUE);
  71.       } else {
  72.          ((Hashtable)this).put("optConc", UNIQUE_MODIFIED);
  73.       }
  74.    }
  75.  
  76.    public void setInitialRecordPosition(String setting) {
  77.       if (setting.equals("First")) {
  78.          ((Hashtable)this).put("recPosition", REC_POS_FIRST);
  79.       } else if (setting.equals("New")) {
  80.          ((Hashtable)this).put("recPosition", REC_POS_NEW);
  81.       } else {
  82.          ((Hashtable)this).put("recPosition", REC_POS_NOPOS);
  83.       }
  84.    }
  85.  
  86.    Session getSession() {
  87.       return this._sess;
  88.    }
  89. }
  90.